--- title: "L1-050 倒数第N个字符串" created: 2025-11-28 tags: - 算法 --- # L1-050 倒数第N个字符串 ## 题目 [L1-050 倒数第N个字符串](https://pintia.cn/problem-sets/994805046380707840/exam/problems/type/7?problemSetProblemId=994805080346181632&page=0) ![[image-c3f33c44.png]] ## 思路分析 将字符串作为26进制的数 与10进制相互转换 ![[image-789f5b13.png]] ## 代码实现 ```cpp #include using namespace std; #define endl '\n' #define int long long using ll = long long; using ull = unsigned long long; using PII = pair; using Pll = pair; int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 }; const int inf = 0x3f3f3f3f; ll qmi(ll a,ll k) { ll res=1; while(k) { if(k&1) res=res*a; k>>=1; a=a*a; } return res; } signed main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int l; cin>>l; int n; cin>>n; ll end=0; // for(int i=0;i ans; while(idx){ ans.push('a'+(idx%26)); idx/=26; } while(ans.size() using namespace std; #define endl '\n' #define int long long using ll = long long; using ull = unsigned long long; using PII = pair; using Pll = pair; int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 }; const int inf = 0x3f3f3f3f; ll qmi(ll a,ll k) { ll res=1; while(k) { if(k&1) res=res*a; k>>=1; a=a*a; } return res; } signed main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int l; cin>>l; int n; cin>>n; ll end=0; // for(int i=0;i ans; for(int i = 0; i < l; ++i){ ans.push('a'+(idx%26)); idx/=26; } while(!ans.empty()) { cout<